﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace LabMS.Web.Equipment.Valuables
{
    public partial class valuablesrepairconform : Base.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            strPagePrivilege.Add("GZSBWXYS");//必须写在ispostback外
            strPageUserType.Add("mana");

            if (!Page.IsPostBack)
            {
                Bind("");
            }
        }

        protected void GridViewValuables_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridViewValuables.PageIndex = e.NewPageIndex;
            if (TextBox1.Text.Trim().Equals(""))
            {
                Bind("");
            }
            else
            {
                string strWhere = " and Name like '%" + TextBox1.Text.Trim() + "%' ";
                Bind(strWhere);
            }
        }

        protected void GridViewValuables_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes["style"] = "Cursor:pointer";
                int itemp = e.Row.Cells.Count;
                for (int i = 0; i < itemp; i++)
                {
                    e.Row.Cells[i].Attributes.Add("OnDblClick", "window.location.href='valuablesconform.aspx?ID=" + GridViewValuables.DataKeys[GridViewValuables.DataKeys.Count - 1].Value.ToString() + "'");
                }
            }
        }

        public void Bind(string strWhere)
        {
            List<ExtendModule.GoodsMaintain> mgoods = new List<ExtendModule.GoodsMaintain>();
            ExtendBLL.GoodsMaintain bgoods = new ExtendBLL.GoodsMaintain();

            mgoods = bgoods.GetExtendModuleList(" Type = 'guizhongyiqi' AND GoodsMaintain.Status = '修复' " + strWhere + " order by GoodsMaintain.ID desc ");
            GridViewValuables.DataSource = mgoods;
            GridViewValuables.DataBind();
        }

        protected void btUpdate_Click(object sender, EventArgs e)
        {
            Bind("");
        }

        protected void btSearch_Click(object sender, EventArgs e)
        {
            if (TextBox1.Text.Trim().Equals(""))
            {
                Bind("");
            }
            else
            {
                string strWhere = " and Name like '%" + TextBox1.Text.Trim() + "%' ";
                Bind(strWhere);
            }
        }
    }
}
